/**
 * Copyright © 2008, EMC Corporation.
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 *
 *     + Redistributions of source code must retain the above copyright notice, 
 *       this list of conditions and the following disclaimer.
 *     + Redistributions in binary form must reproduce the above copyright 
 *       notice, this list of conditions and the following disclaimer in the 
 *       documentation and/or other materials provided with the distribution.
 *     + The name of EMC Corporation may not be used to endorse or promote 
 *       products derived from this software without specific prior written 
 *       permission.
 *
 *      THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 *      "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 
 *      TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
 *      PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 
 *      BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 *      CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 *      SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
 *      INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 *      CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 *      ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 *      POSSIBILITY OF SUCH DAMAGE.
 */
package com.emc.esu.api.rest {
	import flash.events.Event;
	import flash.utils.ByteArray;

	/**
	 * This event is fired by the RestLoader when responses are complete and 
	 * may be used for tracing requests and responses.
	 */
	public class RestResponseEvent extends Event {
		public static const REST_RESPONSE:String = "REST_RESPONSE";

		private var _loader:String;
		private var _responseHeaders:Object;
		private var _httpStatus:int;
		private var _httpStatusLine:String;
		private var _responseBody:ByteArray;
		private var _rawResponse:ByteArray;
		
		public function get loader():String {
			return _loader;
		}
		public function get httpStatus():int {
			return _httpStatus;
		}
		public function get httpStatusLine():String {
			return _httpStatusLine;
		}
		public function get responseHeaders():Object{
			return _responseHeaders;
		}
		public function get responseBody():ByteArray {
			return _responseBody;
		}
		public function get rawResponse():ByteArray {
			return _rawResponse;
		}
		
		public function RestResponseEvent( loader:RestLoader, httpStatus:int, 
			httpStatusLine:String, responseHeaders:Object, 
			responseBody:ByteArray, rawResponse:ByteArray ) {
			
			// We don't keep the loader object itself because there's 
			// memory issues with keeping the buffers in memory.
			this._loader = loader.id;
			this._httpStatus = httpStatus;
			this._httpStatusLine = httpStatusLine;
			this._responseHeaders = responseHeaders;
			this._responseBody = responseBody;
			this._rawResponse = rawResponse;
						
			super( REST_RESPONSE, true, false );
		}
		
	}
}